/*
 * @ddescription: 售后维权详情/商品信息
 * @Author: along
 * @Date: 2020-10-28
 * @Last Modified by: along
 * @Last Modified time: 2020-10-28
 */
<template>
    <div class="orderDetailList">
        <div class="order_header">
            <div
                class="order_nav"
                :style="{minWidth: '932px'}"
            >
                <div
                    v-for="(title,index) in tableHeader"
                    :key="index"
                    class="order_title"
                    :class="'header'+ index"
                    :style="{
                        width: index == 0 ? '372px' : 'auto', flex: index == 0 ? 'none' : '1', minWidth: index == 0 ? '' : '80px', paddingLeft: '0px', paddingRight: '0px', textAlign: 'center'
                    }"
                >
                    {{ title }}
                </div>
            </div>
        </div>
        <div class="order_self">
            <div class="order_wrap">
                <div
                    v-for="(row,index) in table"
                    :key="index"
                    class="order_list"
                    :style="{minWidth: '932px'}"
                >
                    <div class="order_content orderHeight">
                        <div
                            class="order_side"
                            data-info="商品信息"
                            :style="{width: '372px', flex: 'none', alignItems: 'flex-start'}"
                        >
                            <div
                                v-for="(item, key) in row.order_item_list"
                                :key="key"
                                class="order_side_info"
                            >
                                <img
                                    :src="item.goods_info.thumb_pic"
                                    class="order_cover"
                                >
                                <div class="order_product">
                                    <p
                                        v-if="item.goods_info.title"
                                        class="order_title"
                                    >
                                        {{ item.goods_info.title }}
                                    </p>
                                    <p
                                        v-if="item.goods_product_info.goods_specs.length > 0"
                                        class="order_spec"
                                    >
                                        {{ item.goods_product_info.goods_specs | filterSpec }}
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div
                            class="order_side no-padding"
                            data-info="商品单价"
                            :style="{minWidth: '80px'}"
                        >
                            <div
                                v-for="(item, key) in row.order_item_list"
                                :key="key"
                                class="order_side_info"
                            >
                                {{ item.price ? '¥' + item.price : '--' }}
                            </div>
                        </div>
                        <div
                            class="order_side"
                            data-info="下单数量"
                            :style="{minWidth: '80px'}"
                        >
                            <div
                                v-for="(item, key) in row.order_item_list"
                                :key="key"
                                class="order_side_info"
                            >
                                {{ item.num ? item.num + '件' : '--' }}
                            </div>
                        </div>
                        <div
                            class="order_side"
                            data-info="优惠金额"
                            :style="{minWidth: '80px'}"
                        >
                            <div
                                v-for="(item, key) in row.order_item_list"
                                :key="key"
                                class="order_side_info"
                            >
                                {{ item.discount_money ? '¥' + Math.abs(item.discount_money) : '--' }}
                            </div>
                        </div>
                        <div
                            class="order_side"
                            data-info="掌大补贴"
                            :style="{minWidth: '80px'}"
                        >
                            <div
                                v-for="(item, key) in row.order_item_list"
                                :key="key"
                                class="order_side_info"
                            >
                                {{ item.hire_subsidy_money ? '¥' + item.hire_subsidy_money : '--' }}
                            </div>
                        </div>
                        <div
                            class="order_side"
                            data-info="佣金"
                            :style="{minWidth: '80px'}"
                        >
                            <div
                                v-for="(item, key) in row.order_item_list"
                                :key="key"
                                class="order_side_info"
                            >
                                {{ item.commission ? '¥' + item.commission : '--' }}
                            </div>
                        </div>
                        <div
                            class="order_side"
                            data-info="运费"
                            :style="{minWidth: '80px'}"
                        >
                            <div
                                v-for="(item, key) in row.order_item_list"
                                :key="key"
                                class="order_side_info"
                            >
                                {{ item.freight ? '¥' + item.freight : '--' }}
                            </div>
                        </div>
                        <div
                            class="order_side"
                            data-info="退款金额"
                            :style="{minWidth: '80px'}"
                        >
                            <div
                                v-for="(item, key) in row.order_item_list"
                                :key="key"
                                class="order_side_info"
                            >
                                {{ item.refund_money ? '¥' + item.refund_money : '--' }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'OrderSelfDetail',
    props: {
        table: {
            type: Array,
            default: () => {}
        }
    },
    components: {
    },
    data () {
        return {
            maxWidth: false,//横向滚动临界点最大宽度
            tableHeader: ['商品信息','商品单价','下单数量','优惠金额','掌大补贴','佣金','运费','退款金额'],
        };
    },
    watch: {},
    filters: {
        filterSpec (val) {
            let str = '';

            val.forEach(element => {
                str += element.spec_name + ';' + element.spec_value + ';';
            });

            return str;
        }
    },
    mounted () {
        this.init();
    },
    methods: {
        /**
         * @description 初始化页面数据
         */
        init () {
            this.scrollAnsync();
        },

        /**
         * @description 监听横向滚动,触发同步更新
         */
        scrollAnsync () {
            document.querySelector('.order_self').addEventListener('scroll', e => {
                document.querySelector('.order_header').scrollLeft = e.target.scrollLeft > 100 ? e.target.scrollLeft + 3 : e.target.scrollLeft;
            },false);

            document.querySelector('.order_header').addEventListener('scroll', e => {
                document.querySelector('.order_self').scrollLeft = e.target.scrollLeft > 100 ? e.target.scrollLeft - 3 : e.target.scrollLeft;
            },false);
        },

        /**
         * @description 更新列表数据
         */
        update () {
            this.$emit('update');
        }
    }
};
</script>

<style lang="less" scoped>
.orderDetailList {
    width: 100%;
    flex: 1;
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    // nav
    .order_header {
        width: 100%;
        height: 44px;
        overflow: auto;
        &::-webkit-scrollbar {
            width: 0;
            height: 0;
        }
        .order_nav {
            width: auto;
            height: 44px;
            display: flex;
            align-items: center;
            box-sizing: border-box;
            border: 1px #EEEEEE solid;
            background: #F2F2F2;
            .order_title {
                color: #333;
                font-size: 14px;
                font-weight: 500;
                box-sizing: border-box;
                white-space: nowrap;
                // border-left: 1px red solid;
            }
        }
    }
    // table
    .order_self {
        width: 100%;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: auto;
        // border: 1px red solid;
        &::-webkit-scrollbar {
            width: 3px;
            height: 3px;
        }
        .order_wrap {
            flex: 1;
            width: 100%;
            .order_list {
                background: #FBFBFB;
                border-radius: 2px;
                border: 1px #EEEEEE solid;
                border-top: none;
                border-bottom: none;
                // 订单信息
                .order_data {
                    width: calc(100% - 48px);
                    height: 44px;
                    margin-left: 24px;
                    margin-right: 24px;
                    box-sizing: border-box;
                    border-bottom: 1px #EEEEEE solid;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    .order_info {
                        display: flex;
                        align-items: center;
                        .order_category {
                            width: 64px;
                            height: 20px;
                            text-align: center;
                            line-height: 20px;
                            white-space: nowrap;
                            overflow: hidden;
                            color: #F2F2F2;
                            border-radius: 2px;
                            background: #FF8E39;
                            font-size: 12px;
                            margin-right: 12px;
                        }
                        .order_no {
                            color: #333;
                            font-size: 12px;
                        }
                        .order_time {
                            color: #333;
                            font-size: 12px;
                            margin-left: 32px;
                        }
                    }
                    .order_detail {
                        width: 68px;
                        height: 26px;
                        cursor: pointer;
                        text-align: center;
                        line-height: 26px;
                        border-radius: 13px;
                        color: #333;
                        font-weight: 500;
                        font-size: 12px;
                        border: 1px #D7D7D7 solid;
                        margin-right: 44px;
                    }
                }

                //备注
                .order_remark {
                    width: calc(100% - 48px);
                    height: 44px;
                    margin-left: 24px;
                    margin-right: 24px;
                    box-sizing: border-box;
                    border-top: 1px #EEEEEE solid;
                    display: flex;
                    align-items: center;
                    color: #333;
                    font-size: 12px;
                    font-weight: 500;
                    &>p {
                        color: #333;
                        font-size: 12px;
                        font-weight: 400;
                        margin-left: 5px;
                    }
                }

                //内容
                .order_content {
                    display: flex;
                    align-items: center;
                    height: 100%;
                    .order_view {
                        margin: 16px 0;
                        display: flex;
                        align-items: center;
                        height: 100px;
                        box-sizing: border-box;
                        padding-left: 40px;
                        border-right: 1px #EEEEEE solid;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;
                        color: #333333;
                        font-weight: 500;
                        flex: 1;
                        padding: 0 40px;
                        box-sizing: border-box;
                        min-width: 141px;
                        .order_cloum {
                            display: flex;
                            flex-direction: column;
                            align-items: center;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            white-space: nowrap;
                            .order_cloum_name {
                                color: #333;
                                font-size: 14px;
                                font-weight: 500;
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                                width: 120px;
                            }
                            .order_cloum_phone {
                                color: #333;
                                font-size: 14px;
                                font-weight: 500;
                                margin-top: 10px;
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                                width: 120px;
                            }
                            .order_money {
                                color: #EE4E59;
                                font-size: 14px;
                                font-weight: 500;
                            }
                            .order_freight {
                                color: #333333;
                                font-size: 14px;
                                margin-top: 10px;
                            }
                            .order_cloumn_button {
                                width: 100px;
                                height: 30px;
                                color: #ffffff;
                                text-align: center;
                                line-height: 30px;
                                font-size: 12px;
                                margin-top: 12px;
                                cursor: pointer;
                                background: #20A0FF;
                                border-radius: 15px;
                            }
                        }
                        .order_cover {
                            width: 100px;
                            height: 100px;
                            margin-right: 10px;
                        }
                        .order_product {
                            display: flex;
                            flex-direction: column;
                            align-items: center;
                            .order_title {
                                width: 198px;
                                color: #333;
                                font-size: 14px;
                                font-weight: 500;
                                line-height: 20px;
                                overflow : hidden;
                                text-overflow: ellipsis;
                                display: -webkit-box;
                                -webkit-line-clamp: 2;
                                -webkit-box-orient: vertical;
                                margin-bottom: 7px;
                                white-space: normal;
                            }
                            .order_spec {
                                height: 16px;
                                width: 198px;
                                line-height: 16px;
                                color: #666;
                                font-size: 12px;
                                white-space: nowrap;
                                overflow: hidden;
                                text-overflow: ellipsis;
                            }
                        }
                    }
                    .order_side {
                        display: flex;
                        flex-direction: column;
                        flex: 1;
                        align-items: center;
                        // border-right: 1px #EEEEEE solid;
                        height: 100%;
                        // padding: 0 40px;
                        .order_side_info_fatch {
                            width: 100%;
                            box-sizing: border-box;
                            display: flex;
                            justify-content: center;
                            align-items: center;
                            flex-direction: column;
                        }
                        .order_side_bottom {
                            border-bottom: 1px #EEEEEE solid;
                            .order_side_name {
                                color: #333;
                                font-size: 14px;
                                font-weight: 500;
                                width: 150px;
                                line-height: 22px;
                                text-align: center;
                                overflow: hidden;
                            }
                            .order_side_phone {
                                color: #333;
                                font-size: 14px;
                                font-weight: 500;
                                margin-top: 10px;
                            }
                        }
                        .order_side_info {
                            width: 100%;
                            display: flex;
                            height: 132px;
                            align-items: center;
                            justify-content: center;
                            box-sizing: border-box;
                            border-bottom: 1px #EEEEEE solid;
                            font-weight: 500;
                            .order_cover {
                                width: 100px;
                                height: 100px;
                                margin-right: 10px;
                            }
                            .order_product {
                                display: flex;
                                flex-direction: column;
                                align-items: flex-start;
                                .order_title {
                                    width: 222px;
                                    color: #333;
                                    font-size: 14px;
                                    font-weight: 500;
                                    line-height: 20px;
                                    overflow : hidden;
                                    text-overflow: ellipsis;
                                    display: -webkit-box;
                                    -webkit-line-clamp: 2;
                                    -webkit-box-orient: vertical;
                                    margin-bottom: 7px;
                                    white-space: normal;
                                    padding-right: 24px;
                                }
                                .order_spec {
                                    height: 16px;
                                    width: 222px;
                                    line-height: 16px;
                                    color: #666;
                                    font-size: 12px;
                                    white-space: nowrap;
                                    overflow: hidden;
                                    text-overflow: ellipsis;
                                    padding-right: 24px;
                                }
                            }
                        }
                        .order_cloum {
                            display: flex;
                            flex-direction: column;
                            align-items: center;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            white-space: nowrap;
                            .order_cloumn_button {
                                width: 100px;
                                height: 30px;
                                color: #ffffff;
                                text-align: center;
                                line-height: 30px;
                                font-size: 12px;
                                margin-top: 12px;
                                cursor: pointer;
                                background: #20A0FF;
                                border-radius: 15px;
                            }
                        }
                        .order_side_info_fatch:last-child .order_side_info:last-child {
                            border-bottom: none;
                        }
                        .order_side_bottom:last-child {
                            border-bottom: none;
                        }
                    }
                    .no-padding {
                        padding: 0;
                    }
                }
            }

            .payment {
                width: 100%;
                height: 64px;
                box-sizing: border-box;
                border: 1px #EEEEEE solid;
                border-top: none;
                display: flex;
                align-items: center;
                justify-content: flex-end;
                padding-right: 24px;
                .item {
                    display: flex;
                    color: #666;
                    font-size: 14px;
                    margin-left: 32px;
                    .item_content {
                        color: #EE4E59;
                        font-weight: 500;
                        font-size: 16px;
                        margin-left: 6px;
                        position: relative;
                        top: -2px;
                    }
                }
            }
        }
    }
}
</style>

<style lang="less">
.orderDetailList {
    .el-dialog__body {
        padding-left: 64px;
        padding-right: 64px;
    }
}
</style>